#include <bits/stdc++.h>
using namespace std;
int n,m;
double L,V;
int T;
int ans,ans2;
struct CAR{
    double d,v0,a;
    double ed;
    bool operator <(const CAR& rhs) const {
        if(ed!=rhs.ed) return ed<rhs.ed;
        else return d>rhs.d;
    }
}c[100005];
struct DET{
    double s;
    int cnt;
    bool operator <(const DET& rhs) const {
        return s<rhs.s;
    }
}dt[100005];
void init(){
    n=0,m=0,L=0,V=0;
    memset(c,0,sizeof(c));
    memset(dt,0,sizeof(dt));
    ans=ans2=0;
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>T;
    while(T--){
        init();
        scanf("%d%d%lf%lf",&n,&m,&L,&V);
        for(int i=1;i<=n;i++){
            scanf("%lf%lf%lf",&c[i].d,&c[i].v0,&c[i].a);
            c[i].ed=double(((long long)(V)*(long long)(V)-(long long)(c[i].v0)*(long long)(c[i].v0)))/(long long)(2*c[i].a)+c[i].d;
        }
        for(int i=1;i<=m;i++){
            scanf("%lf",&dt[i].s);
        }
        sort(dt+1,dt+m+1);
        sort(c+1,c+n+1);
        for(int i=1;i<=n;i++){
            if(c[i].a<0){
                if(c[i].v0<=V) continue;
                else {
                    int res=0,res2=0;
                    for(int j=1;j<=m;j++){
                        if(dt[j].s>c[i].ed) break;
                        if(c[i].d<=dt[j].s && dt[j].s<=c[i].ed){
                            res=j;
                            if(dt[j].cnt>0) res2=j;
                        }
                    }
                    if(res2!=0) {
                        ans++;
                        dt[res2].cnt++;
                    }
                    else  if(res!=0){
                        ans++;
                        dt[res].cnt++;
                    }
                }
            }
            else if(c[i].a==0){
                if(c[i].v0<=V) continue;
                else {
                    ans++;
                    dt[m].cnt++;
                }
            } else if(c[i].a>0){
                if(c[i].v0>=V||(c[i].ed<dt[m].s&&c[i].v0<V)) {
                        ans++;
                    dt[m].cnt++;
                }
            }

        }
        cout<<ans;
        for(int i=1;i<=m;i++){
            if(dt[i].cnt>0) ans2++;
        }
        cout<<" "<<m-ans2<<endl;
    }
    return 0;
}
